<?php

namespace addons\groupon\listener\order;

use addons\groupon\exception\Exception;
use addons\groupon\model\ActivityGoodsSkuPrice;
use addons\groupon\model\Config;
use addons\groupon\model\Goods;
use addons\groupon\model\GoodsSkuPrice;
use addons\groupon\model\User;
use addons\groupon\model\UserCoupons;

/**
 * 订单退款
 */
class Refund
{
    // 订单同意退款前
    public function GrouponOrderRefundBefore(&$params)
    {
        $order = $params['order'];
        $item = $params['item'];

    }


    // 订单同意退款后
    public function GrouponOrderRefundAfter(&$params)
    {
        $order = $params['order'];
        $item = $params['item'];

        // 订单退款成功
        $user = User::where('id', $order['user_id'])->find();
        $user && $user->notify(
            new \addons\groupon\notifications\Refund([
                'order' => $order,
                'item' => $item,
                'event' => 'refund_agree'
            ])
        );
    }

}
